<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <title>使用redis进行秒杀场景演示</title>
</head>
<body>
<h1>iphone 13 Pro !! 1元秒杀！！</h1>

<form id="msform" th:action="@{/doseckill}"
      enctype="application/x-www-form-urlencoded">
    <input type="hidden" id="prodid" name="prodid" value="0101">
    <input type="button" id="miaosha_btn" name="seckill_btn" value="秒杀点我"/>
</form>
<script type="text/javascript" th:src="@{/js/jquery-1.10.2.min.js}"></script>
<script type="text/javascript">
    $(function () {
        $("#miaosha_btn").click(function () {
            var url = $("#msform").attr("action");
            $.post(url, $("#msform").serialize(), function (data) {
                if (data == "false") {
                    alert("抢光了");
                    $("#miaosha_btn").attr("disabled", true);
                }
            });
        })
    })
</script>
</body>
</html>